import request from 'utils/request'

/*
    地址管理
*/
let config = {
  headers: {
    'Content-Type': 'application/json;charset=UTF-8'  //之前说的以表单传数据的格式来传递fromdata
  }
};

//地址列表(有分页)
export const addressList = params => request.post("/p/addressList", params , config)

//地址列表(没分页，商品详情、购物车页面选择地址专用)
export const address = params => request.get("/address", params , config)


//设置默认收货地址
export const defaultaddress = params => request.post("/p/defaultaddress", params)


//加载收货地址
export const loadAddress = params => request.post("/p/addressDetail", params)

//保存或更新收货地址
export const saveAddress = params => request.post("/p/saveAddress", params , config)


//删除收货地址
export const deladdress = params => request.post("/p/deladdress", params)


//加载所有的省份（地址编码版）
export const loadProvincesForCode = params => request.get("/common/loadProvincesForCode", params)

// 加载某省份下的所有城市地址编码版）
export const loadCitiesForCode = params => request.get("/common/loadCitiesForCode", params)

// 加载某城市下的所有地区（地址编码版）
export const loadAreasForCode = params => request.get("/common/loadAreasForCode", params)

// 加载某地区下的所有乡镇/街道（地址编码版）
export const loadTownsForCode = params => request.get("/common/loadTownsForCode", params)